<!DOCTYPE html>
<html>
<head>
	<!-- Google Tag Manager -->
	<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
	new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
	j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
	'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
	})(window,document,'script','dataLayer','GTM-W8KNPT4');</script>
	<!-- End Google Tag Manager -->
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width,viewport-fit=cover,inital-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no,minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
	<meta name="format-detection" content="telephone=no">
    <title>订单详情</title>
    <link rel="stylesheet" href="css/app.min.css?ver=1.0.000">
    <link rel="stylesheet" href="css/iconfont.css?ver=1.0.000">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
    <script src="js/pageLib.js"></script>
</head>
<body>
<div class="header">
	<div class="nav">
		<div class="title">订单详情</div>
		<a href="orders-list.html" class="left-btn"><i class="iconfont icon-xitongfanhui icon-middle"></i></a>
		<div class="right-btn login-bar">登录 / 注册</div>
		<div class="right-btn user-info-bar" style="display:none;">
			<div class="login flexer">
				<div class="balance">
					<div>余额</div>
					<div>￥888.88</div>
				</div>
				<div class="deposit"><a href="deposit.html">充值</a></div>
			</div>
		</div>
	</div>
</div>
<div class="table-content" style="padding-top:50px;">
	<div class="preload-indicator">
		<span class="preloader"></span>
		<div>正在加载对阵列表...</div>
	</div>
</div>
<div class="order-detail-container"  style="padding-top:50px;display:none;">
	<div class="order-info content-container">
	    <div class="lottery-type">
	        <div class="name">竞彩足球</div>
	        <div class="draw">第<span class="order_draw">0</span>期</div>
	    </div>
	    <div class="ticket-info">
	        <div class="ticket-amount">
	            <div class="label">方案金额</div>
	            <div class="value order_total">￥0</div>
	        </div>
	        <div class="split"></div>
	        <div class="ticket-status">
	            <div class="label">订单状态</div>
	            <div class="value red order_status">已派奖</div>
	        </div>
	        <div class="split"></div>
	        <div class="ticket-prize">
	            <div class="label">税后奖金</div>
	            <div class="value red order_prize">￥0</div>
	        </div>
	    </div>
	</div>
	<div class="order-detail content-container">
		<div class="ticket-intro">
	        <span class="group_type">2串1</span>
	        <span class="notes">1注</span>
	        <span class="multiple">1倍</span>
		</div>
		<div class="ticket-content">
			<table class="ticket-table">
				<thead>
					<tr>
						<th>场次</th>
						<th>主队vs客队</th>
						<th>玩法</th>
						<th>投注</th>
						<th>赛果</th>
					</tr>
				</thead>
				<tbody class="data_info">
					<tr>
						<td>周一006</td>
						<td>马竞<br>vs<br>奥林比亚</td>
						<td>胜平负</td>
						<td>主胜</td>
						<td class="red">主胜</td>
					</tr>
					<tr>
						<td>周一006</td>
						<td>马竞<br>vs<br>奥林比亚</td>
						<td>胜平负</td>
						<td>主胜</td>
						<td>待定</td>
					</tr>
					<tr>
						<td rowspan="2">周一006</td>
						<td rowspan="2">塞尔塔<br>vs<br>皇马</td>
						<td>胜平负</td>
						<td>主胜</td>
						<td>待定</td>
					</tr>
					<tr>
						<td>让球胜平负(-1)</td>
						<td>主胜<br>平手</td>
						<td>待定</td>
					</tr>
					<tr>
						<td rowspan="3">周一006</td>
						<td rowspan="3">阿森纳<br>vs<br>曼联</td>
						<td>胜平负</td>
						<td>主胜[3.57]</td>
						<td>客胜</td>
					</tr>
					<tr>
						<td>让球胜平负(+1)</td>
						<td>主胜[2.20]<br><span class="red">平手[3.20]</span></td>
						<td class="red">平手</td>
					</tr>
					<tr>
						<td>比分</td>
						<td>2:1[5.20]<br><span class="red">1:2[3.20]</span></td>
						<td class="red">1:2</td>
					</tr>
				</tbody>
			</table>
		</div>
	</div>
	<div class="order-footnote">
	    <div><span>订单编号</span>：<span class="order_no"></span></div>
	    <div><span>下单时间</span>：<span class="order_create"></span></div>
	    <div class="order_receipt"></div>
	    <div class="order_out"></div>
	</div>

	<div class="btn-space-holder"></div>
	<div class="goto-lottery toContinue" style="display:none" onClick="returnThePlay();">继续玩竞彩足球</div>
	<div class="goto-lottery toPay"  style="display:none" onClick="returnToPay();">去支付</div>
	<input type="hidden" id="order_no">
	<input type="hidden" id="amount">

</div>
</body>
<script>
 
function returnThePlay(){
	// window.webkit.messageHandlers.ContinueToPlay.postMessage({});
	window.location.href="sporttery.html";
}

function returnToPay(){
	var order_no = $("#order_no").val();
	var amount = $("#amount").val();
	window.webkit.messageHandlers.ImmediatePay.postMessage({
		"order_no":order_no,
		"amount":amount
	});
}
   
$(function() {
	pageLib.initAffiliate();
	pageLib.loadUserInfo();

	var reg = new RegExp("(^|&)order_no=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
	var r = window.location.search.substr(1).match(reg);  //匹配目标参数
	
	if (r != null){
		var order_no = unescape(r[2]);
		//alert(unescape(r[2]));
	}else {
		pageLib.alert('订单参数错误')
	}
	   
	$.get(
		"Api.php/v1/order/order-info?order_no="+order_no,
		function(res){
			if(res.code == 1){
				//console.log(res.data);
				var info = res.data;
				//订单金额
				var total = info.amount;
				$("#amount").val(total);
				$(".order_total").html('￥'+total);
				
				
				//奖金
				var prize = info.aftertaxprize;
				if(prize == '0.00'){
					$(".order_prize").html('￥ --');
				}else {
					$(".order_prize").html('￥'+prize);
				}
				
				
				
				//旗号
				var draw = info.draw;
				$(".order_draw").html(draw);
				
				//串数
				var g_type = info.group_type;
				$(".group_type").html(g_type);
				
				//注数
				var notes = info.notes;
				$(".notes").html(notes+"注");
				
				//倍数
				var multiple = info.multiple;
				$(".multiple").html(multiple+"倍");
				
				var no = info.order_no;
				$("#order_no").val(no);
				$(".order_no").html(no);
				
				var crea = info.created_at;
				$(".order_create").html(crea);
				
				var receipt = info.accept_at;
				if(receipt != "0"){
					$(".order_receipt").html('<span>商家接单</span>：'+receipt+'<span ></span>');
				}
				
				
				var out = info.confirm_at;
				if(out != "0"){
					$(".order_out").html('<span>商家出票</span>：'+out+'<span ></span>');
				}
				
				
				//组装比赛主体
				var match_info = info.data;
				var match_html = '';
				
				for (var i=0;i<match_info.length;i++){
					var sho = match_info[i];
					var count = sho.length;
					
					var tt = 'vs';
					if(sho['home_score'] != '-99'){
						tt = '<span style="font-weight: bold;">'+sho['home_score']+':'+sho['away_score']+'</span>';
					}
					match_html += '<tr><td rowspan="'+match_info[i]['data_count']+'">'+sho['riqi']+'</td>';
					match_html += '<td rowspan="'+match_info[i]['data_count']+'">'+sho['home_name']+'<br>'+tt+'<br>'+sho['away_name']+'</td>';
					var content = match_info[i].content;
					
					for (var n=0;n<content.length;n++){
						var g = false;
						if(n == 0){
							match_html += '<td>'+content[n]['play_name']+'</td>';
						}
						else {
							match_html += '<tr><td>'+content[n]['play_name']+'</td>';
						}
						
						
						//判断sub_arr 的长度
						for(var k=0; k<content[n]['sub_arr'].length; k++){
							var con_sub = content[n]['sub_arr'][k];
							
							if(k !=0){
								match_html += '<br><span>'+con_sub.sel_name+'</span>';
							}else{
								match_html += '<td>'+con_sub.sel_name;
							}
							if(con_sub.result_color == 'red'){
								g = true;
							}
						}
						
						
						if(g == true){
							match_html += '</td><td class="red">'+con_sub.result_name +'</td></tr>';
						}else {
							match_html += '</td><td>'+con_sub.result_name +'</td></tr>';
						}
						
						
					}
				}
				$(".data_info").html(match_html);
				
				
				
				//状态 1待支付 2 支付中 3 待出票 4 待开奖 5 待派奖 6 已派奖 7 未中奖  8 已撤单 9 已过期
				var status = info.status;
				var sta_str ;
				$(".toContinue").show();
				switch(status){
					case "1":
					 sta_str = '待支付';
					 $(".toContinue").hide();
					 $(".toPay").show();
					 break;
					case "2":
					 sta_str = '支付中';
					 break;
					case "3":
					 sta_str = '待出票';
					 break;
					case "4":
					 sta_str = '待开奖';
					 break;
					case "5":
					 sta_str = '待派奖';
					 break;
					case "6":
					 sta_str = '已派奖';
					 break;
					case "7":
					 sta_str = '未中奖';
					 break;
					case "8":
					 sta_str = '已撤单';
					 break;
					case "9":
					 sta_str = '已过期';
					 break;
					default :
					 sta_str = '状态异常';
				}
				$(".order_status").html(sta_str);
				$('.table-content').hide();
				$('.order-detail-container').show();
			}
					
		},
		'json'
	);

});

</script>
</html>